package com.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.domain.Dept;
import com.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    //根据id查找部门信息
    @RequestMapping("/findById")
    @ResponseBody
    public String findById(Integer id){
        Dept dept = deptService.findById(id);
        //将dept转为Json类型的数据返回
        return JSON.toJSONString(dept);
    }
}
